Coherence Configuration Enhancements - Part 1 - Injectables

24
<Insert Picture Here> Coherence 12.1.2 Configuration Enhancements Part 1: @Injectables Brian Oliver Senior Consulting Member of Staff Cloud Application Foundation - Oracle Coherence Oracle Fusion Middleware 12c Cloud Application Foundation Coherence 12.1.2

description

Watch on YouTube: http://www.youtube.com/watch?v=muCC90UMSWY

Transcript of Coherence Configuration Enhancements - Part 1 - Injectables

Page 1: Coherence Configuration Enhancements - Part 1 - Injectables

<Insert Picture Here>

Coherence 12.1.2 Configuration EnhancementsPart 1: @InjectablesBrian OliverSenior Consulting Member of StaffCloud Application Foundation - Oracle Coherence

Oracle Fusion Middleware 12c Cloud Application Foundation

Coherence 12.1.2

Page 2: Coherence Configuration Enhancements - Part 1 - Injectables

2 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

Page 3: Coherence Configuration Enhancements - Part 1 - Injectables

The Agenda…

Page 4: Coherence Configuration Enhancements - Part 1 - Injectables

4 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Coherence 12.1.2 ConfigurationEnhancements…• The Background…

– Everything’s changed… but nothing has changed…

• The Simple Improvements– Introducing @Injectable’s

• Summary

Page 5: Coherence Configuration Enhancements - Part 1 - Injectables

The Objectives…

Page 6: Coherence Configuration Enhancements - Part 1 - Injectables

6 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

The Objectives

• Improve Integration with Third-Party Frameworks– Containers (WLS, GlassFish, et al)– Injection Frameworks (CDI, Spring, Guice et al)– Permit Third-Party & Open Source Development– Allow Independent “plug-in” Development for Coherence Servers

• Allow Extension of Coherence– Add new custom features to Coherence

• Provide Complete* non-Xml Programmatic Configuration

Page 7: Coherence Configuration Enhancements - Part 1 - Injectables

7 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

What’s different?

• Nothing… and everything!

• Internally refactored…– Adopted a new internal Runtime Configuration Model– New Configuration Processing Model… that can be customized

and extended!– Removed dependency on XML

• Existing configurations should work without change

Page 8: Coherence Configuration Enhancements - Part 1 - Injectables

The Simple Improvements…

Page 9: Coherence Configuration Enhancements - Part 1 - Injectables

9 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Old Style Cache Store Configuration<cache-config xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="" xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">

<caching-scheme-mapping> <cache-mapping> <cache-name>dist-*</cache-name> <scheme-name>distributed-scheme</scheme-name> </cache-mapping> </caching-scheme-mapping>

<caching-schemes> <distributed-scheme> <scheme-name>distributed-scheme</scheme-name> <service-name>DistributedCache</service-name>

<backing-map-scheme> <read-write-backing-map-scheme>

<cachestore-scheme> <class-scheme> <class-name>MyOldStyleCacheStore</class-name> </class-scheme> </cachestore-scheme> </read-write-backing-map-scheme> </backing-map-scheme>

<autostart>true</autostart> </distributed-scheme>

</caching-schemes></cache-config>

Page 10: Coherence Configuration Enhancements - Part 1 - Injectables

10 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Old Style Cache Store Configuration

public class MyOldStyleCacheStore extends AbstractCacheStore{ @Override public Object load(Object o) { return null; // we're not going to support loading }

@Override public void store(Object oKey, Object oValue) { System.out.println("Storing Key: " + oKey + ", Value: " + oValue); }

@Override public void erase(Object oKey) { System.out.println("Erasing Key: " + oKey); }}

Page 11: Coherence Configuration Enhancements - Part 1 - Injectables

11 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Old Style (with parameters). . . <caching-schemes> <distributed-scheme> <scheme-name>distributed-scheme</scheme-name> <service-name>DistributedCache</service-name>

<backing-map-scheme> <read-write-backing-map-scheme> <cachestore-scheme> <class-scheme> <class-name>MyOldStyleCacheStoreWithParameters</class-name> <init-params> <init-param> <param-type>string</param-type> <param-name>Cache Name</param-name> <param-value>{cache-name}</param-value> </init-param> </init-params> </class-scheme> </cachestore-scheme> </read-write-backing-map-scheme> </backing-map-scheme> <autostart>true</autostart> </distributed-scheme> </caching-schemes>. . .

Page 12: Coherence Configuration Enhancements - Part 1 - Injectables

12 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Old Style (with parameters)public class MyOldStyleCacheStoreWithParameters extends AbstractCacheStore{ private String m_CacheName;

public MyOldStyleCacheStoreWithParameters(String cacheName) { m_CacheName = cacheName; }

@Override public Object load(Object o) { return null; // we're not going to support loading }

@Override public void store(Object oKey, Object oValue) { System.out.println("Storing Key: " + oKey + ", Value: " + oValue + " for Cache: " + m_CacheName); }

@Override public void erase(Object oKey) { System.out.println("Erasing Key: " + oKey + " for Cache: " + m_CacheName); }}

Page 13: Coherence Configuration Enhancements - Part 1 - Injectables

Introducing @Injectable’s

Page 14: Coherence Configuration Enhancements - Part 1 - Injectables

14 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

New @Injectable Cache Storepublic class InjectableCacheStore extends AbstractCacheStore{ private String m_CacheName;

@Injectable public setCacheName(String cacheName) { m_CacheName = cacheName; }

@Override public Object load(Object o) { return null; // we're not going to support loading }

@Override public void store(Object oKey, Object oValue) { System.out.println("Storing Key: " + oKey + ", Value: " + oValue + " for Cache: " + m_CacheName); }

@Override public void erase(Object oKey) { System.out.println("Erasing Key: " + oKey + " for Cache: " + m_CacheName); }}

Page 15: Coherence Configuration Enhancements - Part 1 - Injectables

15 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

New @Injectable Cache Store<cache-config xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="" xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">

<caching-scheme-mapping> <cache-mapping> <cache-name>dist-*</cache-name> <scheme-name>distributed-scheme</scheme-name> </cache-mapping> </caching-scheme-mapping>

<caching-schemes> <distributed-scheme> <scheme-name>distributed-scheme</scheme-name> <service-name>DistributedCache</service-name>

<backing-map-scheme> <read-write-backing-map-scheme> <cachestore-scheme> <class-scheme> <class-name>InjectableCacheStore</class-name> </class-scheme> </cachestore-scheme> </read-write-backing-map-scheme> </backing-map-scheme> <autostart>true</autostart> </distributed-scheme> </caching-schemes></cache-config>

Page 16: Coherence Configuration Enhancements - Part 1 - Injectables

16 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Introducing @Injectables

• Applicable when Coherence is provided with an Object…– It will attempt to initialize it with appropriate @Injectables– Based on the “context” of Object usage– Before it uses the Object for the first time

• eg: For <class-scheme> Coherence will try to inject…– cache-name, manager-context– ConfigurableCacheFactory, ClassLoader– Any other Named/Typed Resource from the Resource Registry

Page 17: Coherence Configuration Enhancements - Part 1 - Injectables

17 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Introducing @Injectables

• Javadoc defines what can be injected with @Injectable– Look in com.tangosol.coherence.config package

• @Injectable’s Property Resolution…– Automatically uses Camel-Case of Setter Method to find a property

• “setCacheName” method becomes “cache-name” property

– Or… optionally specify “exact name” of the property@Injectable(“cache-name”)

public void setSomeMethodName(String name)

{ …

}

Page 18: Coherence Configuration Enhancements - Part 1 - Injectables

18 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Introducing @Injectables

• Where does this apply?– ClassScheme’s aka: <class-scheme>– Instance’s aka: <instance>– … customized namespaces!

• Where not?– <partition-listener>

Page 19: Coherence Configuration Enhancements - Part 1 - Injectables

Summary

Page 20: Coherence Configuration Enhancements - Part 1 - Injectables

20 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Summary

• Coherence 12.1.2 introduces @Injectable annotation– Provides type-safe object injection– Automatically determines property names and types– Help reduces XML configuration requirement

Page 21: Coherence Configuration Enhancements - Part 1 - Injectables

21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Next Part?

• Using Objects from other frameworks– Native integration – Avoiding the use of statics

Page 22: Coherence Configuration Enhancements - Part 1 - Injectables

Join the Coherence Community

http://coherence.oracle.com

@OracleCoherence

/OracleCoherence

blogs.oracle.com/OracleCoherence

Group: Oracle Coherence Users

/OracleCoherence

coherence.oracle.com/display/CSIGCoherence Special Interest Group

Page 23: Coherence Configuration Enhancements - Part 1 - Injectables

23 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

The proceeding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

Page 24: Coherence Configuration Enhancements - Part 1 - Injectables

<Insert Picture Here>

Coherence 12.1.2 Configuration EnhancementsPart 1: @InjectablesBrian OliverSenior Consulting Member of StaffCloud Application Foundation - Oracle Coherence

Oracle Fusion Middleware 12c Cloud Application Foundation

Coherence 12.1.2