-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alexander Pinčuk <alexander.v.pinchuk@gmail.com>
- Loading branch information
Showing
14 changed files
with
913 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...main/java/org/glassfish/main/test/app/persistence/transform/ejb/ClassTransformerBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.main.test.app.persistence.transform.ejb; | ||
|
||
import jakarta.ejb.Stateless; | ||
import jakarta.persistence.EntityManagerFactory; | ||
import jakarta.persistence.PersistenceUnit; | ||
|
||
@Stateless | ||
public class ClassTransformerBean { | ||
|
||
@PersistenceUnit(unitName = "transformPU") | ||
private EntityManagerFactory persistenceUnit; | ||
|
||
public String getResult() { | ||
return null; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...java/org/glassfish/main/test/app/persistence/transform/provider/ClassTransformerImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.main.test.app.persistence.transform.provider; | ||
|
||
import jakarta.persistence.spi.ClassTransformer; | ||
|
||
import java.security.ProtectionDomain; | ||
|
||
public class ClassTransformerImpl implements ClassTransformer { | ||
|
||
@Override | ||
public byte[] transform(ClassLoader loader, | ||
String className, | ||
Class<?> classBeingRedefined, | ||
ProtectionDomain protectionDomain, | ||
byte[] classfileBuffer) { | ||
// Produces circular attempts of transformation. | ||
return Enhancer.enhance(classfileBuffer, new EnhancerContext()); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...on/src/main/java/org/glassfish/main/test/app/persistence/transform/provider/Enhancer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.main.test.app.persistence.transform.provider; | ||
|
||
public class Enhancer { | ||
|
||
public static byte[] enhance(byte[] classfileBuffer, EnhancerContext context) { | ||
return classfileBuffer; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...main/java/org/glassfish/main/test/app/persistence/transform/provider/EnhancerContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.main.test.app.persistence.transform.provider; | ||
|
||
public class EnhancerContext { | ||
|
||
} |
107 changes: 107 additions & 0 deletions
107
.../org/glassfish/main/test/app/persistence/transform/provider/EntityManagerFactoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.main.test.app.persistence.transform.provider; | ||
|
||
import jakarta.persistence.Cache; | ||
import jakarta.persistence.EntityGraph; | ||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.EntityManagerFactory; | ||
import jakarta.persistence.PersistenceUnitUtil; | ||
import jakarta.persistence.Query; | ||
import jakarta.persistence.SynchronizationType; | ||
import jakarta.persistence.criteria.CriteriaBuilder; | ||
import jakarta.persistence.metamodel.Metamodel; | ||
import jakarta.persistence.spi.PersistenceUnitInfo; | ||
|
||
import java.util.Map; | ||
|
||
public class EntityManagerFactoryImpl implements EntityManagerFactory { | ||
|
||
public EntityManagerFactoryImpl(PersistenceUnitInfo persistenceUnitInfo) { | ||
persistenceUnitInfo.addTransformer(new ClassTransformerImpl()); | ||
} | ||
|
||
@Override | ||
public EntityManager createEntityManager() { | ||
return new EntityManagerImpl(); | ||
} | ||
|
||
@Override | ||
public EntityManager createEntityManager(Map properties) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public EntityManager createEntityManager(SynchronizationType synchronizationType) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public EntityManager createEntityManager(SynchronizationType synchronizationType, Map properties) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public CriteriaBuilder getCriteriaBuilder() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Metamodel getMetamodel() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isOpen() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
|
||
} | ||
|
||
@Override | ||
public Map<String, Object> getProperties() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Cache getCache() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public PersistenceUnitUtil getPersistenceUnitUtil() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void addNamedQuery(String name, Query query) { | ||
|
||
} | ||
|
||
@Override | ||
public <T> T unwrap(Class<T> cls) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public <T> void addNamedEntityGraph(String graphName, EntityGraph<T> entityGraph) { | ||
|
||
} | ||
} |
Oops, something went wrong.